package com.dxk.config;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class interceptFilter implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("进入过滤器");
        String session = (String) request.getSession().getAttribute("user");
        System.out.println(session);
        if (session==null){
            request.setAttribute("hint","权限不足，请登入账号");
            request.getRequestDispatcher("/index.html").forward(request,response);
            return  false;
        }
        return true;
    }

}
